<?php

namespace common\models;

use Yii;
use yii\behaviors\TimestampBehavior;

/**
 * This is the model class for table "{{%venue_photo}}".
 *
 * @property integer $id
 * @property integer $venue_id
 * @property string $path
 * @property string $base_url
 * @property string $type
 * @property integer $size
 * @property string $name
 * @property integer $order
 * @property string $upload_ip
 * @property integer $created_at
 */
class VenuePhoto extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%venue_photo}}';
    }

    public function behaviors()
    {
        return [
            [
                'class' => TimestampBehavior::className(),
                'updatedAtAttribute' => false
            ]
        ];
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['venue_id', 'size'], 'required'],
            [['venue_id', 'size', 'order', 'created_at'], 'integer'],
            [['path', 'base_url'], 'string', 'max' => 255],
            [['type', 'name'], 'string', 'max' => 100],
            [['upload_ip'], 'string', 'max' => 15]
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'id',
            'venue_id' => '会场id',
            'path' => '路径',
            'base_url' => '基础url',
            'type' => '类型',
            'size' => '大小',
            'name' => '文件名',
            'order' => '排序',
            'upload_ip' => '上传ip',
            'created_at' => '创建时间',
        ];
    }

    public function getGoods()
    {
        return $this->hasOne(Venue::className(), ['id' => 'venue_id']);
    }
}
